package com.sdgakj.repository;

import com.sdgakj.entity.FeedComment;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.List;

public interface FeedCommentDao extends PagingAndSortingRepository<FeedComment, Long>, JpaSpecificationExecutor<FeedComment> {
	
	/**
	 * 时间轴评论
	 * 
	 * @param feedId
	 * @param sinceId
	 * @param maxId
	 * @param pageSize
	 * @return
	 */
    public List<FeedComment> findTimeline(Long feedId, Long sinceId, Long maxId, Integer pageSize);
    
    /**
     * 根据feedid分页查询未删除评论
     * @return
     */
    public List<FeedComment> findPageComment(Long feedId, Integer pageNumber, Integer pageSize);
    
    /**
     * 查询未删除贴子的所有评论
     * @param feedId
     * @return
     */
    public Long getTotalCount(Long feedId);

	/**
	 * 查询某条评论的总数
	 * */

	@Query(value = "select count(1) from f_feed_comment where feed_id=?1 and deltag='0'",nativeQuery = true)
	public Integer getFeedCommentCount(Long feedId);
	@Query(value = "select * from f_feed_comment where feed_id=?1 and deltag='0'",nativeQuery = true)
	public List<FeedComment> getFeedCommentList(Long feedId);
}

